---
title: Standard BOF persistence lifecycle
summary: Create/retrieve/update/delete each business entity through Criteria SQL properties.
status: draft
owner: SAIF Documentation Generator
last_reviewed: 2026-08-26
library: SAIF.Business.Claim.Legal
reference_type: embedded
operation_id: standard-bof-persistence-lifecycle
trigger: Save(), Create(), or Delete() is called on any business entity in this library
---

# Standard BOF persistence lifecycle

The library's inline-SQL business entities (e.g. `clsLegalSchedule`, `clsAppeal`, `clsAppealExtension`)
follow the standard SAIF BOF framework persistence lifecycle: each entity exposes `Create()`/`Save()`/
`Delete()` operations that resolve to Criteria-defined SQL properties and the framework's
`Before*`/`After*` hook pattern.

| Field | Value |
| --- | --- |
| **Operation ID** | standard-bof-persistence-lifecycle |
| **Trigger** | `Save()` / `Create()` / `Delete()` on any entity |
| **Inputs** | Entity property values |
| **Outputs** | Persisted row, `RowsAffected` contention check |
| **Primary components** | Each entity's `BeforeInsert`/`AfterInsert`/`BeforeUpdate`/`AfterUpdate`/`BeforeDelete`/`AfterDelete` overrides |
| **Entry point** | Per-entity `.vb` source files (see [SQL catalog](../sql/index.md) for the per-class Criteria SQL properties) |

## Steps

1. A caller calls `Create()`, `Save()`, or the entity's own delete method.
2. The framework's inherited data-portal machinery routes the call to the appropriate Criteria SQL
   property (Insert/Update/Delete) generated for the entity.
3. `Before*` hooks (`BeforeInsert`/`BeforeUpdate`/`BeforeDelete`) run first to prepare or validate the
   request.
4. The framework executes the resolved SQL/stored-procedure statement against Oracle.
5. `After*` hooks (`AfterInsert`/`AfterUpdate`/`AfterDelete`) run afterward. Each checks
   `RowsAffected <> 1` and raises `AddErrorMessage("InsertError"/"UpdateError"/"DeleteError",
   clsConstants.Messages.DBContentionError)` when the check fails — the library-wide
   optimistic-concurrency (lost-update) control.
6. Unsupported CRUD operations on a `Criteria` class throw `New
   ApplicationException(clsConstants.Messages.InvalidSQLProperty)` rather than silently no-oping.

## Process flow

```mermaid
flowchart TD
	Start(["Create / Save /<br>Delete called"]) --> Before["Before* hook runs"]
	Before --> Exec["Framework executes<br>Criteria SQL"]
	Exec --> After["After* hook runs"]
	After --> Check{"RowsAffected = 1?"}
	Check -->|Yes| EndOk(["Persistence<br>succeeded"])
	Check -->|No| Err(["Contention error<br>raised"])
```

## Failure and edge-case behavior
- `RowsAffected <> 1` in any `After*` hook raises a contention error rather than silently succeeding.
- Calling an unsupported CRUD operation on a `Criteria` class throws `ApplicationException` with
  `InvalidSQLProperty`.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Database tables](../database-tables.md)
- [SQL catalog](../sql/index.md)

## Sources
- `SAIF.Business.Claim.Legal\LegalNet\clsLegalSchedule.vb`
- `SAIF.Business.Claim.Legal\LegalNet\clsAppeal.vb`
